<?php
namespace app\serveruser\validate;
use \app\manage\validate\BaseValidate;
/**
 * 菜单的验证类
 * @author adv30 <adv30@126.com> 2017年6月15日17:06:59
 */
class Menu extends BaseValidate
{
    // 是否使用true基础的验证规则
    // protected $useBaseRules = false;
    protected $rule = [
        'menu_cate_id' => ['integer', 'gt'=>'0'],
        'name' => ['alphaNum', 'length'=>'2,20'],
        'name_cn' => ['chsAlphaNum', 'length'=>'2,20'],
        'type' => ['in'=>['menu','button','nav']],
        'url' => ['url'],
        'merge_auth' => ['length'=>'4,128'],
        'auth_data' => ['regex'=>'^{.*}$'],
        'auth_id' => ['integer','gt'=>'0'],
        'pid' => ['integer', 'gt'=>'0'],
        'level' => ['integer', 'gt'=>'1'],
        'id' => ['integer', 'gt'=>'0'],
        'menu_id' => ['integer', 'gt'=>'0'],
        'role_id' => ['integer', 'gt'=>'0'],
        'parent_menu_id' => ['integer', 'gt'=>'0'],
        'role_ids' => ['regex' => '^(\d)+(,\d+)*'],
    ];
    protected $message = [
    ];
    protected $scene = [
        'addTop' => ['menu_cate_id', 'name', 'name_cn', 'order', 'type', 'url', 'merge_auth', 'auth_data', 'auth_id'],
        'add' => ['menu_cate_id', 'name', 'name_cn', 'order', 'type', 'url', 'merge_auth', 'auth_data', 'auth_id', 'pid', 'level'],
        'edit' => ['id','menu_cate_id', 'name', 'name_cn', 'order', 'pid', 'level'],
        'treeByCate' => ['menu_cate_id'],
        'stop' => ['id'],
        'move' => ['id', 'pid'],
        'treeByAppKey' => ['app_key'],
        'addShowMenuAuthByRole' => ['menu_id', 'role_id'],
        'addShowMenuAndChildren' => ['parent_menu_id', 'role_id'],
        'treeByRolesAndAppkey' => ['app_key', 'role_ids'],
        'stopShowMenuAuthByRole' => ['id', 'menu_id', 'role_id'],
        'startShowMenuAuthByRole' => ['id', 'menu_id', 'role_id'],
        'stopShowMenuAndChildren' => ['id', 'menu_id', 'role_id'],
        'startShowMenuAndChildren' => ['id', 'menu_id', 'role_id'],
    ];
}
